import request from '@/utils/request'

// 登录
export function userLogin(account, password, verifyCode) {
    return request({
        url: '/user/login',
        method: 'post',
        headers: {
            isToken: false
        },
        data: { 'account': account, 'password': password, "verifyCode": verifyCode }
    })
}
// 注册
export function userRegister(account, password, email,school) {
    return request({
        url: '/user/register',
        method: 'post',
        headers: {
            isToken: false
        },
        data: { "account": account, "password": password, "email": email, role: "招聘方" ,"school":school}
    })
}
// 忘记密码页面找回密码
export function findPassword(email, password) {
    return request({
        url: '/user/find',
        method: 'put',
        headers: {
            isToken: false
        },
        data: { "email": email, "password": password }
    })
}

export function logout() {
    return request({
        url: '/logout',
        method: 'post',
        headers: {
            isToken: true
        },
    })
}

export function getUserInfo(userId) {
    return request({
        url: '/user/userInfo',
        method: 'get',
        headers: {
            isToken: true
        },
        params: { "userId": userId }
    })
}


export function saveUserInfo(userinfo) {
    return request({
        url: '/user/userInfo',
        method: 'put',
        headers: {
            isToken: true
        },
        data: userinfo
    })
}

export function getAuthorInfo(userId) {
    return request({
        url: '/user/authorInfo',
        method: 'get',
        headers: {
            isToken: false
        },
        params: { "userId": userId }
    })
}
export function getCode(data) {
    return request({
        url: '/user/getCode',
        method: 'get',
        params: { "email": data }
    })
}
export function judgeCode(data) {
    return request({
        url: '/user/judgeCode',
        method: 'get',
        params: { "email": data.email ,"code":data.code}
    })
}

//登录状态重置密码
export const resetPassword = (oldPassword, newPassword) => {
    return request.put("/forgotPassword/loginResetPassword", {
        oldPassword,
        newPassword,
    });
};